package com.jadcon.bedbreakfast.domain;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("customerService")
public class CustomerServiceImpl implements CustomerService {

	@Autowired
	private CustomerRepository customerRepository;

	public List<Customer> findByID(int id) {
		return customerRepository.findByID(id);
	}

	public List<Customer> findByName(String name) {
		return customerRepository.findByName(name);
	}

	public void save(Customer customer) {
		customerRepository.save(customer);
	}

	public void delete(int id) {
		customerRepository.delete(id);
	}

	public List<State> getStateList() {
		return customerRepository.getStateList();
	}
	
	public Customer findByUsername(String username) {
		return customerRepository.findByUsername(username);
	}
	
	public List<Customer> getCustomerList() {
		return customerRepository.getCustomerList();
	}


	public Boolean usernameAvailable(Customer customer) {

		Boolean available = false;
		String username = customer.getUsername();
		if (username.equals(customerRepository.findByUsername(username))){
			available = false;
		} else {
			available = true;
		}	
		return available;
	}


}

